#include "StdAfx.h"
#include "ClientNotificationHandler.h"
#include "Libs/Native/Common/FastLogger.h"

#include <sstream>

ClientNotificationHandler::ClientNotificationHandler(void)
{
}

ClientNotificationHandler::~ClientNotificationHandler(void)
{
}

void ClientNotificationHandler::OnNotification(const AlgoTrading::Messages::NotificationMessage& notification)
{
	std::wostringstream os;
	os << L"NotificationMessage recieved: requestType " << static_cast<int>(notification.GetNotificationMessageType());
	std::wstring* logEntry = new std::wstring(os.str());
	AlgoTrading::Logging::fastLogger.Log((void*) logEntry, AlgoTrading::Logging::FastLogger::WIDE_STRING);
}

void ClientNotificationHandler::OnRequestResponse(const AlgoTrading::Messages::RequestResponse& response)
{
	std::wostringstream os;
	os << L"RequestResponse recieved: requestType " << static_cast<int>(response.GetRequestResponseMessageType());
	std::wstring* logEntry = new std::wstring(os.str());
	AlgoTrading::Logging::fastLogger.Log((void*) logEntry, AlgoTrading::Logging::FastLogger::WIDE_STRING);

}

void ClientNotificationHandler::OnError(const boost::system::error_code& error)
{
	std::ostringstream os;
	os << "Error occured: " << error.message();
	std::string* logEntry = new std::string(os.str());
	AlgoTrading::Logging::fastLogger.Log((void*) logEntry, AlgoTrading::Logging::FastLogger::STRING);
}

void ClientNotificationHandler::OnDisconnect()
{
	std::ostringstream os;
	os << "Client disconnected";
	std::string* logEntry = new std::string(os.str());
	AlgoTrading::Logging::fastLogger.Log((void*) logEntry, AlgoTrading::Logging::FastLogger::STRING);
}
